﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Collections;

namespace iResume
{
    public partial class createJobseeker : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                SetCaptchaText();
                Label9.Text = (string)Session["Captcha"];

            }
            fullnametxb.Focus();

           
        }

        private void SetCaptchaText()
        {
            Random oRandom = new Random();
            int iNumber = oRandom.Next(100000, 999999);
            Session["Captcha"] = iNumber.ToString();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (Label9.Text != wvTxb.Text)
            {
                Panel5.Visible = true;
            }
            else
            {
                Panel5.Visible = false;
                ArrayList validateJEmail = new ArrayList();
                validateJEmail = DBManager.retrieveJEmail();

                foreach (string mail in validateJEmail)
                {
                    if (mail == emailtxb.Text)
                    {
                        Label10.Visible = true;
                    }
                }

                if (Label10.Visible == false)
                {
                    string fullName = fullnametxb.Text;
                    string emailAdd = emailtxb.Text;

                    string repassword = retypepasswordtxb.Text;
                    string category = categorydpb.Text;

                    string HashedPassword = "";


                    //This is to hash the new password user have
                    HashedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(retypepasswordtxb.Text, "sha1");
                    retypepasswordtxb.Text = HashedPassword;


                    fullnametxb.Text = "";
                    emailtxb.Text = "";

                    retypepasswordtxb.Text = "";
                    categorydpb.Text = "";
                    wvTxb.Text = "";

                    JobSeeker j = new JobSeeker(fullName, emailAdd, HashedPassword, repassword, category);
                    DBManager myDBManager = new DBManager();
                    DBManager.createJobSeeker(j);
                    Response.Redirect("createJobSeekerAcctSuccess.aspx");
                }

            }

          
         
            }

        protected void wvTxb0_TextChanged(object sender, EventArgs e)
        {

        }

        protected void termsckb_CheckedChanged(object sender, EventArgs e)
       
        {
            if (termsckb.Checked == true)
            {
                Button1.Enabled = true;
                Button1.Focus();
                //string temp = FileUploadImage
            }
            else
            {

                Button1.Enabled = false;

            }

        }

        
        
        }
        }
    
